<template>
	<view class="page">
		<!-- 		<u-navbar title="全部订单" @leftClick="$goBack(5,'/pages/my/my')" :autoBack="true">
		</u-navbar> -->

		<dropdown-list :show="shows" :top="0" :height="400">
			<template v-slot:selectionbox>
				<view class="top">
					<view class="top-name" @click="dropDownList(-1)">
						<view>{{orders}}</view>
						<u-icon name="arrow-down"></u-icon>
						<u-line length="16" direction="col" margin="0rpx 20rpx"></u-line>
					</view>

				</view>
			</template>
			<template v-slot:dropdownbox>
				<view class="tui-selected-list">
					<scroll-view scroll-y class="tui-dropdown-scroll">
						<block v-for="(item,index) in dropdownlistData" :key="index">
							<!-- <tui-list-cell padding="0"
								:unlined="dropdownlistData.length-1==index"> -->
							<view class="tui-cell-class" @click="dropDownList(item)">
								<text class="tui-ml-20">{{item.name}}</text>
							</view>
							<!-- </tui-list-cell> -->
						</block>
					</scroll-view>
				</view>
			</template>
		</dropdown-list>

		<view style="font-size: 24rpx; margin: 20rpx;">共<text style="color:#257CFF">{{lists.length}}</text>条数据</view>
		<view class="content" v-for="(item,index) in lists" :key="index">
			<view class="order-top">
				<view class="le">
					<view class="statebg" v-if="item.status==20" style="background-color: #5B6784;"></view>
					<view class="statebg" v-else-if='item.status==40' style="width: 100rpx;background-color: #FF4D4F;">
					</view>
					<view class="statebg" v-else-if="item.status==30" style="background-color: #1677FF;"></view>
					<view class="statebg" v-else-if="item.status==50" style="background-color: #1677FF; width: 160rpx;">
					</view>
					<view class="statebg" v-else style="background-color: #23860E;"></view>

					<view v-if="item.status==20" class="state">待到店</view>
					<view v-else-if='item.status==40' class="state">待审核</view>
					<view v-else-if='item.status==30' class="state">待诊断</view>
					<view v-else-if='item.status==50' class="state">维修/保养中</view>
					<view v-else class="state">已完成</view>

					<view class="process" v-if="item.status==40">审核中</view>
					<view class="processs" v-else-if='item.status==30&&item.refundPersonName!=""'>审核未通过</view>
				</view>
				<view class="re" v-if="item.orderCategory==1">维保订单</view>
				<view class="re" v-else>维修订单</view>
			</view>
			<view class="store">{{item.storeInfocopy.name}}</view>
			<view class="order-content">
				{{item.productNameStr}}
			</view>
			<view class="time">{{item.createTime}}</view>
			<view class="but">
				<view v-if="item.orderCategory==1"
					@click="$goBack(2,'/bundle/pages/maintenanceorderdetails/maintenanceorderdetails?id='+item.id)">更多
				</view>
				<view v-else @click="$goBack(2,'/bundle/pages/repairdetails/repairdetails?id='+item.id)">更多</view>
				<view class="button">
					<view style="display: flex;" @click="phone(item.storeInfocopy.phone)">
						<u-icon color="#257CFF" name="phone" />
						<text>联系商家</text>
					</view>
					<view
						@click="$goBack(2,`/bundle/pages/convolutioncode/convolutioncode?id=${item.id}&time=${item.createTime}`)">
						出示卷码</view>
					<view v-if="item.orderCategory==1"
						@click="$goBack(2,'/bundle/pages/maintenanceorderdetails/maintenanceorderdetails?id='+item.id)">
						查看详情</view>
					<view v-else @click="$goBack(2,'/bundle/pages/repairdetails/repairdetails?id='+item.id)">查看详情</view>

				</view>
			</view>
		</view>
		<u-empty v-if="lists.length==0" text="暂无数据">
		</u-empty>
		<u-action-sheet :actions="list" @select="selectClick" :show="show"></u-action-sheet>
	</view>
</template>

<script>
	import DropdownList from '../../../components/tui-dropdown-list/tui-dropdown-list.vue'
	import {
		apigetStoreOrderList
	} from '@/api/orders.js'
	export default {
		data() {
			return {
				orders: '订单状态',
				dropdownlistData: [{
						name: '全部订单',
						status: null
					},
					{
						name: "待到店",
						status: 20
					},
					{
						name: "待重新审核",
						status: 30
					},
					{
						name: "待服务",
						status: 40
					},
					{
						name: "维修/ 保养中",
						status: 50
					},
					{
						name: "已完成",
						status: 80
					},

				],
				lists: [],
				show: false,
				shows: false,

			}
		},
		components: {
			DropdownList,
		},
		onLoad() {
			this.selectDetailByTime()
		},
		methods: {
			dropDownList(item) {
				if (item == -1) {
					this.shows = !this.shows
					return
					// this.tui.toast("index：" + index)
				}
				this.orders = item.name
				this.selectDetailByTime(item.status)
				this.shows = !this.shows
			},
			selectClick(e) {
				this.show = false
			},
			selectDetailByTime(status = null) {
				uni.showLoading({
					title: '加载中'
				})
				let params = {
					"driverId": uni.getStorageSync("caruser").driverId,
					status: status
				}
				console.log(params)
				apigetStoreOrderList(params).then((res) => {
					uni.hideLoading()
					this.lists = res.data.records

				}).catch((err) => {
					uni.hideLoading()
				})
			},
			phone(i) {
				wx.makePhoneCall({
					phoneNumber: i
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.tui-drop-input-box {
		padding: 50rpx;
		box-sizing: border-box;
	}

	.tui-animation {
		display: inline-block;
		transform: rotate(0deg);
		transition: all 0.2s;
	}

	.tui-animation-show {
		transform: rotate(180deg);
	}

	.tui-selected-list {
		background-color: #fff;
		border-radius: 20rpx;
		overflow: hidden;
		transform: translateZ(0);
	}

	.tui-dropdown-scroll {
		height: 400rpx;
	}

	.tui-cell-class {
		display: flex;
		align-items: center;
		padding: 26rpx 30rpx !important;
	}

	.tui-ml-20 {
		margin-left: 20rpx;
		font-size: 24rpx
	}

	.top {
		// margin-top: 150rpx;
		padding: 20rpx;
		height: 84rpx;
		font-size: 28rpx;
		background-color: #fff;
		text-align: center;

		@include flex(row, left) .top-name {
			padding-left: 50rpx;
			box-sizing: border-box;
			width: 300rpx;
			display: flex;

		}
	}

	.content {
		width: 718rpx;
		// height: 308rpx;
		margin: 16rpx;
		padding: 26rpx 20rpx;
		box-sizing: border-box;
		background-color: #fff;
		border-radius: 20rpx;

		.order-top {
			@include flex(row, space-between, center) .le {
				position: relative;
				display: flex;

				.statebg {
					position: absolute;
					width: 96rpx;
					height: 40rpx;

					transform: skew(-10deg);
				}

				.state {
					z-index: 9999;
					font-size: 24rpx;
					color: #fff;
					margin: 2rpx 16rpx;
				}

				.order-name {
					font-size: 34rpx;
					font-weight: 600;
					margin: -2rpx 10rpx;
				}

				.process {
					border: solid 2rpx #1677FF;
					padding: 6rpx 20rpx;
					font-size: 26rpx;
					color: #1677FF;
					background-color: #BAE0FF;
					border-radius: 10rpx;
					margin-left: 10rpx;

				}

				.processs {
					border: solid 2rpx #FF4D4F;
					padding: 6rpx 20rpx;
					font-size: 26rpx;
					color: #FF4D4F;
					background-color: #FFCCC7;
					border-radius: 10rpx;
					margin-left: 10rpx;
				}
			}

			.re {
				font-size: 28rpx;
				color: #257CFF;
			}

		}

		.store {
			font-size: 26rpx;
			margin: 8rpx 0rpx;
		}

		.order-content {
			width: 666rpx;
			font-size: 24rpx;
			color: #666666;
			margin-bottom: 6rpx;
		}

		.time {
			margin-bottom: 8rpx;
			color: #949494;
			font-size: 24rpx;
		}

		.but {
			margin-top: 8rpx;
			font-size: 30rpx;
			color: #257CFF;

			@include flex(row, space-between, center) .button {
				color: #2E2E2E;
				display: flex;

				view {
					border: solid 2rpx #979797;
					border-radius: 10rpx;
					margin-right: 10rpx;
					padding: 5rpx 10rpx;
					font-size: 24rpx;
				}
			}
		}

	}

	::v-deep .u-popup__content {
		// position: absolute !important; 

		background-color: rgba(0, 0, 0, 0.5) !important
	}

	::v-deep .u-transition {
		// position: absolute !important; 
		top: 120rpx !important;
	}
</style>